package com.fzrskj.cloud.free.dic.utils;

import com.fzrskj.cloud.free.dic.bean.DicParamIndex;
import com.fzrskj.cloud.free.dic.dao.DicParamIndexDao;
import ms.core.consts.SysErr;
import ms.core.object.CObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DicParamIndexUtils extends CObject{
	/**
	 * 获取数据字典
	 * @param paramType
	 * @return
	 */
	public List<DicParamIndex> getSysParamIndexList(int paramType) {
		DicParamIndexDao dao =new DicParamIndexDao();
		List<DicParamIndex> list = dao.getSysParamIndexList(paramType);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return list;
	}
	/**
	 * 通过英文名查询字段
	 * @param paramEName
	 * @param pramType
	 * @return
	 */
	public DicParamIndex getSysParamIndexByEName(String paramEName,int pramType) {
		DicParamIndexDao dao =new DicParamIndexDao();
		DicParamIndex sys = dao.getSysParamIndexByEName(paramEName, pramType);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return sys;
	}

	/**
	 * 查询指定id列表
	 * @param paramType
	 * @param ids
	 * @return
	 */
	public List<DicParamIndex> getSysParamIndexListByIds(int paramType,String ids) {
		DicParamIndexDao dao =new DicParamIndexDao();
		List<Integer> IdList = new ArrayList<Integer>();
		String[] IdString = ids.split(",");
		for(int i=0;i<IdString.length;i++){
			IdList.add(Integer.valueOf(IdString[i].trim()));
		}
		List<DicParamIndex> list = dao.getSysParamIndexListByIds(paramType, IdList);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return list;
	}
	/**
	 * 根据id与paramEName删除对应的数据字典表
	 * @param id
	 * @param paramEName
	 * @return
	 */
	public int delSysParamindex(int id,String paramEName){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.delSysParamindex(id,paramEName);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;

	}
	public int updateParamIndex(DicParamIndex dicParamIndex){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.updateParamIndex(dicParamIndex);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public int addSysParamindex(DicParamIndex obj){
		//判断输入的英文字典是否重复
		int i = 0;
		if(getSysParamIndexByEName(obj.getParamEName(), 0) != null){
			this.setErrCode(SysErr.SYS_DATA_EXISTS);
			return i;
		}
		DicParamIndexDao dao =new DicParamIndexDao();
		i = dao.addSysParamindex(obj);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public int addSysParamindex(Map<String, Object> values){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.addSysParamindex(values);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public int delSysParamindex(Map<String, Object> cdt){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.delSysParamindex(cdt);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public int modSysParamindex(Map<String, Object> values, Map<String, Object> cdt){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.modSysParamindex(values, cdt);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public DicParamIndex querySysParamindex(int id){
		DicParamIndexDao dao =new DicParamIndexDao();
		DicParamIndex sys = dao.querySysParamIndex(id);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return sys;
	}
	public int querySysParamindex(Map<String, Object> cdt){
		DicParamIndexDao dao =new DicParamIndexDao();
		int i = dao.querySysParamindex(cdt);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return i;
	}
	public List<DicParamIndex> querySysParamindexList(Map<String, Object> cdt, int page, int pagesize){
		DicParamIndexDao dao =new DicParamIndexDao();
		List<DicParamIndex> list = dao.querySysParamindexList(cdt, page, pagesize);
		String code = dao.getErrCode();
		this.setErrCode(code);
		dao.dispose();
		return list;
	}
}